<template>
	<view>
		<view style="background-color: #f8f8f8;width: 100%;height: 100%;">
			<view style="display: flex;justify-content: center;width: 100vw;flex-direction: column;align-items: center;background-color: #fff;margin-bottom: 10px;">
				<view :style="{'height':clientType!='pda'?'100px':'40px'}"  style="width: 100vw;background-color: #007AFF;"></view>
				<view><image src="../../static/images/user.png" style="width: 50px;height: 50px;margin-top: -35px;z-index: 100;border-radius: 50%;"></image></view>
				<view @click="payorder" :style="{'font-size':clientType=='pda'?'20px':'16px'}"><text>{{username}},{{welmsg}}!</text></view>
			</view>
			<view v-for="(item, index) in settingarr2" :key="index" style="width: 100%; background-color: #fff;">
				<view style="display: flex;justify-content: space-between;align-items: center;padding: 10px;" @click="navito(item.url)">
					<view style="display: flex;align-items: center;" :style="{'font-size':clientType=='pda'?'20px':'16px'}"><image :src="item.picicon" style="width: 20px;height: 20px;padding-right: 10px;"></image>{{item.title}}</view>
					<view><text class="iconfont icon-jiantou"></text></view>
				</view>
				<view style="height: 1px;background-color: #eee;"></view>
			</view>
			
			
			
			<!-- <view class="container">
			  <button open-type="contact" class="customer-service-btn">
			    联系客服
			  </button>
			</view> -->
			<tabbar :value2='4'></tabbar>
		</view>
		
	</view>
</template>


<script>
	var util = require("../../utils/util.js");
	const app = getApp().globalData;
	import tabbar from "@/components/tabbar/tabbar.vue"
	export default {
		components:{
			tabbar:tabbar
		},
		data() {
			return {
				isShowUser: false,
				username: '',
				logintype: '',
				typename: '',
				meInfolists: [],
				isLoadMe: false,
				isLoadIndex: false,
				isstore:true,
				clientType:'',
				welmsg:'欢迎回来',
				enObj:[{"picicon":"../../static/images/mine.png","title":"My account","url":"/pages/myaccount/myaccount"},
							{"picicon":"../../static/images/all.png","title":"Change password","url":"/pages/pwd/pwd"},
							
							{"picicon":"../../static/images/all.png","title":"Log out","url":"relogin"}],
				settingarr2:[{"picicon":"../../static/images/mine.png","title":"我的账号","url":"/pages/myaccount/myaccount"},
							{"picicon":"../../static/images/all.png","title":"修改密码","url":"/pages/pwd/pwd"},
							
							{"picicon":"../../static/images/all.png","title":"退出登录","url":"relogin"}]
			}
		},
		//放到settingarr2里面 {"picicon":"../../static/images/all.png","title":"小程序二维码","url":"/pages/xcx/xcx"},
		onLoad:function(options){
			var that = this
			uni.hideTabBar()
			uni.setNavigationBarColor({backgroundColor:'#e63332',frontColor:'#fff'})
			that.username = uni.getStorageSync('userName')
			this.clientType = uni.getStorageSync('clientType')
			var productCode = uni.getStorageSync('productCode')
			var sessionId = uni.getStorageSync('sessionId')
			var projectCode = uni.getStorageSync('projectCode')
			var terminaltype = uni.getStorageSync('terminaltype')
			var dbId = uni.getStorageSync('dbId')
			var userId = uni.getStorageSync('userId')
			var userName = uni.getStorageSync('userName')
			uni.$emit('getbus','aaa')
			
			let clientType = uni.getStorageSync('clientType')
			if(clientType === 'pda'){
				let broadsetyw = {"picicon":"../../static/images/all.png","title":"Broadcast Setting","url":"/pages/brset/brset"}
				let broadsetzw = {"picicon":"../../static/images/all.png","title":"广播设置","url":"/pages/brset/brset"}
				this.settingarr2.splice(2,0,broadsetzw)
				this.enObj.splice(2,0,broadsetyw)
			}else{
				let gzhyw = {"picicon":"../../static/images/all.png","title":"Follow official account","url":"/pages/gzh/gzh"}
				let gzhzw = {"picicon":"../../static/images/all.png","title":"关注公众号","url":"/pages/gzh/gzh"}
				this.settingarr2.splice(2,0,gzhzw)
				this.enObj.splice(2,0,gzhyw)
			}
			let  i18n = uni.getStorageSync('i18n')
			if(i18n === 'en'){
				uni.setNavigationBarTitle({'title':'Mine'})
				this.settingarr2 = this.enObj
				this.welmsg = 'Welcome back'
			}
			
		},
		onShow:function(){
			uni.hideTabBar()
		},
		
		methods:{
				
			payorder(){
				var vm = this;
				if (typeof WeixinJSBridge == "undefined"){
				if( document.addEventListener ){
					document.addEventListener('WeixinJSBridgeReady', vm.onBridgeReady(), false);
				}else if (document.attachEvent){
					document.attachEvent('WeixinJSBridgeReady', vm.onBridgeReady());
					document.attachEvent('onWeixinJSBridgeReady',vm.onBridgeReady());
				}
				}else{
				vm.onBridgeReady();
				}
						
			},
				
			relogin() {
				uni.showModal({
					title: '提示',
					content: '是否退出登录?',
					success: function (res) {
						if (res.confirm) {
							that.$store.commit('changeTabBarIndex',0)
							uni.setStorageSync('sessionId', '');
							uni.reLaunch({
								url:'../register/register'
							})	
						}
					}
				})
			},
			
			navito(url){
				var that = this
				console.log(url)
				if(url=='relogin'){
					uni.showModal({
						title: '提示',
						content: '是否退出登录?',
						success: function (res) {
							if (res.confirm) {
								that.$store.commit('changeTabBarIndex',0)
								uni.setStorageSync('sessionId', '');
								uni.reLaunch({
									url:'../register/register'
								})	
							}
						}
					})
				}else{
					uni.navigateTo({url:url})
				}
			},
			
			navitoorder(){
				uni.navigateTo({url:'/pages/myorder/myorder'})
			}
		}
	}
		
		
			
</script>

<style>
	.customer-service-btn {
	  margin: 20px auto;
	  background-color: #1aad19;
	  color: white;
	  border-radius: 8px;
	  padding: 10px;
	  font-size: 16px;
	  text-align: center;
	}
</style>
